<include file="__THEME__/header" />
<link href="../Public/css/space.css" rel="stylesheet" type="text/css" />
<div class="contents lbg B">
  <!--左边信息 begin--->
  <include file="../Public/home_left" />
  <!--中间信息 begin-->
  <div class="contents_min w787">
    <h3 class="tit_h3">上传头像</h3>
    <p class="f12 cl03 mb10 pl5"> <img class="alM pr5" src="../Public/images/title_icon_17.gif" /> 个人空间基本信息设置，完善你的资料，让更多人了解你，展示你的更多信息。 </p>
    <div class="list_cate_nav">
      <div class="tab">
        <ul>
          <volist id="vo" name="topmenu">
            <php>$class=($type==$key)?'class="sam_status on"':''</php>
            <li {$class}><span><a href="{$vo.url}" >{$vo.info}</a></span>{:$_GET['act']}</li>
          </volist>
        </ul>
      </div>
    </div>
    <div class="C"></div>
    <div class="base_input">
      <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
        <tr>
          <td width="163" valign="top" align="center"><div id="userfacediv" class="len_bbs_userpic">
              <div style="padding:5px;width:120px; border:1px solid #ddd"> <img src="{$mid|getUserFace}?t={:time()}" id="user_big_face" /> </div>
              <div style="margin-top:20px;padding:5px;width:50px;border:1px solid #ddd""> <img src="{$mid|getUserFace='s'}?t={:time()}" id="user_small_face" width="50" height="50" /> </div>
            </div></td>
          <td align="left"><include file="_corpface" />
            <div id="face_upload" style="width:304px; float:left;">
              <h3 class="lh30 f14">上传头像</h3>
              <p class="cl03 lh22"><span>1.&nbsp;&nbsp;支持JPG、GIF和PNG格式的图片文件，大小2M以内。</span><br />
                <span>2.&nbsp;&nbsp;建议使用大头照，不然缩小后可能看不清楚。</span><br />
                <span>3.&nbsp;&nbsp;请“浏览”大图，上传头像；您也可以拖动图片，手工调整选择头像区域。</span></p>
              <div style="margin:20px 0 30px 0; line-height:18px;"> {:W('UploadAttach',array('type'=>'face','allow_size'=>'2M','allow_exts'=>'png,jpg,gif,jpeg,bmp','callback'=>'set_bigimage') )} </div>
            </div>
            <div class="clewbox L">
              <div class="clewbox_bg">温馨提示：</div>
              <div class="clewbox_bg_b">请确认上传的是你自己的照片。上传色情、反动等照片将导致你的账号被删除。</div>
            </div></td>
        </tr>
      </table>
    </div>
  </div>
  <!--中间信息 begin-->
  <div class="C"></div>
</div>
<!-- 截头像开始 -->
<script type="text/javascript">
//全局变量定义
var CANVAS_WIDTH	=	320; //画布的宽
var CANVAS_HEIGHT	=	320; //画布的高
var ICON_WIDTH		=	120;  //截取框的宽
var ICON_HEIGHT		=	120;  //截取框的高
var TOP_EDGE		=	100;
var LEFT_EDGE		=	100;
</script>
<script type="text/javascript" src="__PUBLIC__/js/kxthumb/thumb.js"></script>
<script type= "text/javascript">

//设置截取框大图
function set_bigimage(info){
	$('#kxface').show();
	$('#face_upload').hide();
	//上传目录
	var upload_url	=	'__UPLOAD__';
	var big_image	=	upload_url + '/'+info.savepath+info.savename;
	kxface_set_bigimage(big_image);

	setTimeout(function(){	
		$('#morebig').click();
	},50);

	setTimeout(function(){	
		$('#morebig').click();
	},500);
}

//重新上传
function reupload(){
	$('#kxface').hide();
	$('#face_upload').show();
}

//预览头像
function yulan(obj){
	var bigImage		=	obj.bigImage.value;
	var txt_width		=	obj.txt_width.value;
	var txt_height		=	obj.txt_height.value;
	var txt_top			=	obj.txt_top.value;
	var txt_left		=	obj.txt_left.value;
	var txt_DropWidth	=	obj.txt_DropWidth.value;
	var txt_DropHeight	=	obj.txt_DropHeight.value;
	var txt_Zoom		=	obj.txt_Zoom.value;
	var attach_id		=	obj.attach_id.value;

	$.post(
		"__ROOT__/index.php?app=home&mod=Attach&act=thumbImage",
		{bigImage:bigImage,txt_width:txt_width,txt_height:txt_height,txt_top:txt_top,txt_left:txt_left,txt_DropWidth:txt_DropWidth,txt_DropHeight:txt_DropHeight,txt_Zoom:txt_Zoom},
		function(txt){
			if(txt==-1){
				alert('图片截取失败！');
			}else{
				//alert(txt);
				info	=	eval('('+txt+')');
				
				//alert(info.big + '-' + info.small);
				//$("#user_big_face").attr('src',info.big+'?t='+Math.random());
				//$("#user_small_face").attr('src',info.small+'?t='+Math.random());
				$.tbox.yes('<span style="font-size:16px;">头像设置成功！请按 <font color=red>F5</font> 刷新页面！</span>','设置头像');
				//alert('头像设置成功，如果头像没有变化，请按 ctrl+F5 刷新头像！');
				//window.location.href = '{:U("home/Info/userface","t=".time())}';
				//savePic(txt,attach_id);
			}
		}
	);
	return false;
}
//保存头像
function savePic(picpath,attach_id){
	if(!$.trim(picpath)) {
		alert('请上传图片！！')
	}else{
		$.post('cp.php?ac=profile&op=avatar',{formhash:formhash,saveavatar:1,picpath:picpath},function(txt){
			if(txt ==1){
				$('#avatar_img').attr('src',picpath);
				$.facebox.close();
			}else{
				alert('上传失败');
			}
		});
	}
}
</script>
<!-- 截头像结束 -->
<include file="__THEME__/footer" />